


Array.prototype.myMap2 = function (callback,thisArg) {
    let res = []
    if (!Object.prototype.toString.call(callback).includes('Function')) {
        throw new Error('不是函数')
    }
    else {
        for (let i = 0; i < this.length; i ++) {
            res.push(callback(this[i], i, this))
        }
    }
    return res
}

function add(current,index,array) {
    return current + ':' + index + ':' + array[index]
}
const arr = [1, [2, 3, [4, 5, [10, 12]]], 1, 2, [6, 7]]
console.log(arr.myMap2(add))
